package com.example.shop.goods.dto;

import com.example.shop.pojo.Goods;
import com.example.shop.pojo.GoodsClass;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.data.elasticsearch.annotations.Document;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@Data
@NoArgsConstructor
@Accessors(chain = true)
@Document(indexName = "goods-detail-browse-info",createIndex = false)
public class GoodsBrowseInfo extends GoodsBriefInfo implements Serializable {

    /**
     * 该商品被购买的次数
     */
    protected int purchasedTime;
    /**
     * 该商品的款式型号列表
     */
    protected List<GoodsStyle> goodsStyleList;

    public GoodsBrowseInfo(long goodsId){
        this.goodsId = goodsId;
    }

    @Override
    public String toString() {
        return "GoodsBrowseInfo{" +
                super.toString() +
                ", purchasedTime=" + purchasedTime +
                ", goodsStyleList=" + goodsStyleList +
                '}';
    }
    public GoodsBrowseInfo assignment(Goods goods,List<String> goodsDescriptionPicture,List<GoodsStyle> goodsStyleList){
        super.assignment(goods,goodsDescriptionPicture);
        this.setPurchasedTime(goods.getPurchasedTime())
                .setGoodsStyleList(goodsStyleList);
        return this;
    }
}
